<%@ page language="java" import="java.util.*" import="com.gxuwz.medical.domain.role.*" pageEncoding="utf-8" %>
<%
	String roleid =request.getParameter("roleid");
	roleid = new String(roleid.getBytes("ISO-8859-1"),"UTF-8");
	Role r =new Role();
	r.setRoleid(roleid);
	r=r.query();
 %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="../../css/styles.css">
<link rel="stylesheet" href="../../css/admin.css">
<link href="../../third/zTree_v3/css/zTreeStyle/zTreeStyle.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="../../third/zTree_v3/js/jquery-1.4.4.min.js"></script>
<script src="../../js/admin.js"></script>
<script type="text/javascript" src="../../third/zTree_v3/js/jquery.ztree.all.min.js"></script>
<script type="text/javascript">
	$(function() {
		var ret;
		$.ajax({
			cache : true,
			type : "post",
			url : "tree.right?roleid=<%=roleid%>",
			data : "{}",
			async : false,
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				alert(XMLHttpRequest.status);
				alert(XMLHttpRequest.readyState);
				alert(textStatus);
			},
			success : function(data) {
				console.log(data);
				ret = JSON.parse(data);
				console.log(ret.name);
			
			}
		});

				var setting = {
					check : {
						enable : true,
						chkStyle : "checkbox",//显示 checkbox 选择框，默认checkbox可选择值radio
						chkboxType: { "Y": "ps", "N": "ps" }
					},
					data: {
					   simpleData: {
					   enable: false, //设置是否启用简单数据格式（zTree支持标准数据格式跟简单数据格式，上面例子中是标准数据格式）
					   idKey: "id", //设置启用简单数据格式时id对应的属性名称
					   pidKey: "pid" //设置启用简单数据格式时parentId对应的属性名称,ztree根据id及pid层级关系构建树结构
					  	}
					  }
				};
				var city = $.fn.zTree.init($("#ztree"), setting, ret);	
		//第一个参数为zTree的DOM容器，第二个为zTree设置详情可见官网api,第三个为zTree的节点数据 
	});
	function send(){
		var treeobj = $.fn.zTree.getZTreeObj("ztree");
    	var node_checked = treeobj.getCheckedNodes(true);
    	var list = new Array();
    	for(var i=0;i<node_checked.length;i++){
    		list.push(node_checked[i].id);
    	}
    	var id =JSON.stringify(list)
    	console.log("selected node:"+id);	
    	document.getElementById("editrole").action="edit.role?id="+id;
	}
	</script>
</head>
<body>

<div class="panel admin-panel">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>修改角色</strong></div>
  <div class="body-content">
    <form method="post" class="form-x" action="" id="editrole">  
      <div class="form-group">
        <div class="label">
          <label>角色编码：</label>
        </div>
        <div class="field">
          <input  type="text" class="input w50" value="<%=r.getRoleid()%>" name="roleid"  disabled="disabled"/>
          <input  type="text" class="input w50" value="<%=r.getRoleid()%>" name="roleid"  style="display: none"/>
	    </div>
      </div>
      
      
      <div class="form-group">
        <div class="label">
          <label>角色名称：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="<%=r.getRoleName()%>" name="roleName" data-validate="required:请输入姓名" />
	    </div>
      </div>
      
      <div class="form-group">
        <div class="label">
          <label>权限：</label>
        </div>
      <div class="field">
          <ul id="ztree" class="ztree" style="width:230px; overflow:auto;"></ul>
	    </div>
      </div>   
         
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-check-square-o" onclick="send();" type="submit"> 提交</button>
        </div>
      </div>
      
    </form>
  </div>
</div>

</body></html>